#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
 

class Solution {
public:
    int majorityElement(vector<int>& nums) {
        map<int,int> M;
        for(int i = 0;i<nums.size();++i){
            ++M[nums[i]];
        }
        int result;
        int Max = INT16_MIN;
        for(auto i = M.begin();i!=M.end();++i){
            if(i->second>Max){
                Max = i->second;
                result = i->first;
            }
  
        }
        return result;
    }
};